home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!xs4all!falstaff
- From: falstaff@xs4all.nl (Falstaff)
- Newsgroups: comp.lang.c
- Subject: Re: Limiting stdin input to "n" chars
- Date: 16 Mar 1996 20:17:10 GMT
- Organization: XS4ALL, networking for the masses
- Message-ID: <4if7k6$9ro@news.xs4all.nl>
- References: <4hqfmc$un7@thorn.cc.usm.edu> <4icer1$df5@altrade.nijmegen.inter.nl.net>
- NNTP-Posting-Host: xs1.xs4all.nl
- X-Newsreader: NN version 6.5.0 #666 (NOV)
-
- Auke.Reitsma@net.HCC.nl (Auke Reitsma) writes:
-
- >rmfulce@ocean.st.usm.edu (Mike Fulce) wrote:
-
- >> How do you limit the number of characters read from stdin? What I want to do
- >> is to automatically do a carriage return after a user enters say.. 2 digits.
- >> I've written a few programs using scanf to get input, but it won't work for
- >> what I need now. (I think it's because scanf is buffered I/O?).
-
- >Do character by character input with e.g. getch() or getchar()
- >/* (Non-ISO/ANSI) */
-
- getchar() is defined in ANSI C (paragraph 7.9.7.6 if you want to
- look it up).
-
- >or fgetc( stdin ) /* ISO/ANSI */
- >Or use fgets( your_buffer, number_of_chars, stdin ) /* ANSI */
-
- No won't work. fgets() uses the standard I/O library which will
- wait for a linefeed anyway.
-
- Frank
- --
- The famous GIICM now on line: http://www.xs4all.nl/~falstaff/GIICM.html
- ------------------------------------------------------------------------
- Frank A. Vorstenbosch +31-(70)-355 5241 falstaff@xs4all.nl
-